package nancal.mp.db.es.table

import java.io.*
import nbcp.myoql.db.*
import nbcp.myoql.db.es.*
import nbcp.myoql.db.comm.*
import nbcp.myoql.db.enums.*
import nbcp.myoql.db.es.component.*
import nbcp.base.utils.*
import nbcp.base.extend.*
import nbcp.myoql.db.es.base.*
import org.slf4j.LoggerFactory
import org.springframework.stereotype.*



@Component("es.system")
@MetaDataGroup(DatabaseEnum.ElasticSearch, "system")
class SystemGroup : IDataGroup {
    override fun getEntities():Set<BaseMetaData<out Any>> = setOf(appCallLog,creditEntity,systemDustbinEntity,systemLogEntity,esZaoInformation,fileLog,nginxLogIndex,orderMain,productIndex)
    val appCallLog get() = AppCallLogEntity();
    fun appCallLog(collectionName:String) = AppCallLogEntity(collectionName);
    val creditEntity get() = CreditEntityEntity();
    fun creditEntity(collectionName:String) = CreditEntityEntity(collectionName);
    val systemDustbinEntity get() = SystemDustbinEntityEntity();
    fun systemDustbinEntity(collectionName:String) = SystemDustbinEntityEntity(collectionName);
    val systemLogEntity get() = SystemLogEntityEntity();
    fun systemLogEntity(collectionName:String) = SystemLogEntityEntity(collectionName);
    val esZaoInformation get() = EsZaoInformationEntity();
    fun esZaoInformation(collectionName:String) = EsZaoInformationEntity(collectionName);
    val fileLog get() = FileLogEntity();
    fun fileLog(collectionName:String) = FileLogEntity(collectionName);
    val nginxLogIndex get() = NginxLogIndexEntity();
    fun nginxLogIndex(collectionName:String) = NginxLogIndexEntity(collectionName);
    val orderMain get() = OrderMainEntity();
    fun orderMain(collectionName:String) = OrderMainEntity(collectionName);
    val productIndex get() = ProductIndexEntity();
    fun productIndex(collectionName:String) = ProductIndexEntity(collectionName);



    @nbcp.base.db.annotation.DbName(value = """app-call-log""")
    @nbcp.base.db.annotation.DbEntityGroup(value = """system""")
    @nbcp.myoql.db.comm.IkFieldDefine(fieldNames = arrayOf("""appPackageName""", """appType""", """callLog"""))
    class AppCallLogEntity(indexName: String = "app-call-log"):
        EsBaseMetaEntity<nancal.mp.db.es.AppCallLog>(nancal.mp.db.es.AppCallLog::class.java, indexName) {
        val id = EsColumnName("id")
        val userId = EsColumnName("userId")
        val createBy = EsColumnName("createBy")
        val appName = EsColumnName("appName")
        val createAt = EsColumnName("createAt")
        val appType = EsColumnName("appType")
        val updateAt = EsColumnName("updateAt")
        val callLog = EsColumnName("callLog")
        val appPackageName = EsColumnName("appPackageName")

    }


    @nbcp.base.db.annotation.DbName(value = """credit""")
    @nbcp.base.db.annotation.DbEntityGroup(value = """system""")
    class CreditEntityEntity(indexName: String = "credit"):
        EsBaseMetaEntity<nancal.mp.db.es.CreditEntity>(nancal.mp.db.es.CreditEntity::class.java, indexName) {
        val appList = CreditEntityAppListModelMeta("appList")
        val buriedPointList = CreditEntityBuriedPointListModelMeta("buriedPointList")
        val calendarInfoList = CreditEntityCalendarInfoListModelMeta("calendarInfoList")
        val callLogList = CreditEntityCallLogListModelMeta("callLogList")
        val callbackUrl = EsColumnName("callbackUrl")
        val contactList = CreditEntitycontactListModelMeta("contactList")
        val creditInfo = CreditEntityCreditInfoModelMeta("creditInfo")
        val deviceInfo = CreditEntityDeviceInfoModelMeta("deviceInfo")
        val emerContactList = CreditEntityEmerContactListModelMeta("emerContactList")
        val formatPhotoInfoList = EsColumnName("formatPhotoInfoList")
        val idCardOcrInfo = CreditEntityIdCardOcrInfoModelMeta("idCardOcrInfo")
        val idNo = EsColumnName("idNo")
        val jobInfo = CreditEntityJobInfoModelMeta("jobInfo")
        val marketFeeRateLevel = EsColumnName("marketFeeRateLevel")
        val merchantId = EsColumnName("merchantId")
        val personInfo = CreditEntityPersonInfoModelMeta("personInfo")
        val phone = EsColumnName("phone")
        val realName = EsColumnName("realName")
        val restMap = CreditEntityRestMapModelMeta("restMap")
        val sign = EsColumnName("sign")
        val smsList = CreditEntitySmsListModelMeta("smsList")

    }


    @nbcp.base.db.annotation.DbName(value = """sys-dustbin""")
    @nbcp.base.db.annotation.DbEntityGroup(value = """system""")
    class SystemDustbinEntityEntity(indexName: String = "sys-dustbin"):
        EsBaseMetaEntity<nancal.mp.db.es.SystemDustbinEntity>(nancal.mp.db.es.SystemDustbinEntity::class.java, indexName) {
        val id = EsColumnName("id")
        val appName = EsColumnName("appName")
        val tableName = EsColumnName("tableName")
        val userId = EsColumnName("userId")
        val userName = EsColumnName("userName")
        val createAt = EsColumnName("createAt")
        val data = EsColumnName("data")

    }


    @nbcp.base.db.annotation.DbName(value = """sys-log""")
    @nbcp.base.db.annotation.DbEntityGroup(value = """system""")
    @nbcp.myoql.db.comm.IkFieldDefine(fieldNames = arrayOf("""module""", """msg""", """remark""", """requestUrl""", """requestHeaders""", """requestBody""", """responseHeaders""", """responseBody""", """aopErrorType""", """aopErrorMessage""", """aopClassType""", """aopMethodName"""))
    class SystemLogEntityEntity(indexName: String = "sys-log"):
        EsBaseMetaEntity<nancal.mp.db.es.SystemLogEntity>(nancal.mp.db.es.SystemLogEntity::class.java, indexName) {
        val id = EsColumnName("id")
        val appName = EsColumnName("appName")
        val module = EsColumnName("module")
        val userId = EsColumnName("userId")
        val userName = EsColumnName("userName")
        val msg = EsColumnName("msg")
        val remark = EsColumnName("remark")
        val requestUrl = EsColumnName("requestUrl")
        val requestMethod = EsColumnName("requestMethod")
        val requestHeaders = EsColumnName("requestHeaders")
        val requestBody = EsColumnName("requestBody")
        val responseStatus = EsColumnName("responseStatus")
        val responseHeaders = EsColumnName("responseHeaders")
        val responseBody = EsColumnName("responseBody")
        val tags = EsColumnName("tags")
        val aopErrorType = EsColumnName("aopErrorType")
        val aopErrorMessage = EsColumnName("aopErrorMessage")
        val aopErrorStacks = EsColumnName("aopErrorStacks")
        val aopClassType = EsColumnName("aopClassType")
        val aopMethodName = EsColumnName("aopMethodName")
        val aopMethodParameter = ObjectMeta("aopMethodParameter")
        val aopMethodResult = ObjectMeta("aopMethodResult")

    }


    @nbcp.myoql.db.comm.DbDefines(value = arrayOf(nbcp.myoql.db.comm.DbDefine(define = """{"type":"text","index":"true","analyzer":"ik_max_word","search_analyzer":"ik_max_word"}""", fieldName = """title"""), nbcp.myoql.db.comm.DbDefine(define = """{"type":"text","index":"true","analyzer":"ik_max_word","search_analyzer":"ik_max_word"}""", fieldName = """content"""), nbcp.myoql.db.comm.DbDefine(define = """{"type":"text","index":"true","analyzer":"ik_max_word","search_analyzer":"ik_max_word"}""", fieldName = """remark""")))
    @nbcp.base.db.annotation.DbEntityGroup(value = """system""")
    class EsZaoInformationEntity(indexName: String = "es-zao-information"):
        EsBaseMetaEntity<nancal.mp.db.es.entity.EsZaoInformation>(nancal.mp.db.es.entity.EsZaoInformation::class.java, indexName) {
        val uuid = EsColumnName("uuid")
        val type = EsColumnName("type")
        val title = EsColumnName("title")
        val content = EsColumnName("content")
        val image = EsColumnName("image")
        val remark = EsColumnName("remark")
        val price = EsColumnName("price")
        val tgName = ObjectMeta("tgName")

    }


    @nbcp.base.db.annotation.DbName(value = """file-log""")
    @nbcp.myoql.db.comm.DbDefine(define = """
    {
        "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
        }
    }
    """, fieldName = """path""")
    @nbcp.base.db.annotation.DbEntityGroup(value = """system""")
    @nbcp.myoql.db.comm.IkFieldDefine(fieldNames = arrayOf("""path""", """query""", """requestBody""", """responseBody""", """msg"""))
    class FileLogEntity(indexName: String = "file-log"):
        EsBaseMetaEntity<nancal.mp.db.es.entity.FileLog>(nancal.mp.db.es.entity.FileLog::class.java, indexName) {
        val serviceName = EsColumnName("serviceName")
        val traceId = EsColumnName("traceId")
        val requestId = EsColumnName("requestId")
        val logLevel = EsColumnName("logLevel")
        val isRequest = EsColumnName("isRequest")
        val path = EsColumnName("path")
        val query = EsColumnName("query")
        val ip = EsColumnName("ip")
        val recvAt = EsColumnName("recvAt")
        val appName = EsColumnName("appName")
        val execMilliSeconds = EsColumnName("execMilliSeconds")
        val triggerAt = EsColumnName("triggerAt")
        val adjustId = EsColumnName("adjustId")
        val pkgName = EsColumnName("pkgName")
        val deviceId = EsColumnName("deviceId")
        val userId = EsColumnName("userId")
        val requestBody = EsColumnName("requestBody")
        val status = EsColumnName("status")
        val responseBody = EsColumnName("responseBody")
        val remark = EsColumnName("remark")
        val sort = EsColumnName("sort")
        val createAt = EsColumnName("createAt")
        val msg = EsColumnName("msg")
        val netMilliSeconds = EsColumnName("netMilliSeconds")
        val totalMilliSeconds = EsColumnName("totalMilliSeconds")
        val id = EsColumnName("id")

    }


    @nbcp.base.db.annotation.DbName(value = """ngin-log""")
    @nbcp.myoql.db.comm.DbDefines(value = arrayOf(nbcp.myoql.db.comm.DbDefine(define = """{"type":"text","index":"true","analyzer":"ik_max_word","search_analyzer":"ik_max_word"}""", fieldName = """url"""), nbcp.myoql.db.comm.DbDefine(define = """{"type":"text","index":"true","analyzer":"ik_max_word","search_analyzer":"ik_max_word"}""", fieldName = """referer"""), nbcp.myoql.db.comm.DbDefine(define = """{"type":"text","index":"true","analyzer":"ik_max_word","search_analyzer":"ik_max_word"}""", fieldName = """agent""")))
    @nbcp.base.db.annotation.DbEntityGroup(value = """system""")
    class NginxLogIndexEntity(indexName: String = "ngin-log"):
        EsBaseMetaEntity<nancal.mp.db.es.entity.NginxLogIndex>(nancal.mp.db.es.entity.NginxLogIndex::class.java, indexName) {
        val ip = EsColumnName("ip")
        val visitAt = EsColumnName("visitAt")
        val method = EsColumnName("method")
        val url = EsColumnName("url")
        val referer = EsColumnName("referer")
        val status = EsColumnName("status")
        val agent = EsColumnName("agent")
        val createAt = EsColumnName("createAt")
        val updateAt = EsColumnName("updateAt")
        val id = EsColumnName("id")

    }


    @nbcp.base.db.annotation.DbName(value = """order_main""")
    @nbcp.base.db.annotation.DbEntityGroup(value = """system""")
    class OrderMainEntity(indexName: String = "order-main"):
        EsBaseMetaEntity<nancal.mp.db.es.entity.OrderMain>(nancal.mp.db.es.entity.OrderMain::class.java, indexName) {
        val accountState = EsColumnName("accountState")
        val activePayStartTime = EsColumnName("activePayStartTime")
        val activePayTime = EsColumnName("activePayTime")
        val appraiseState = EsColumnName("appraiseState")
        val autarky = EsColumnName("autarky")
        val cashBackMoney = EsColumnName("cashBackMoney")
        val changeState = EsColumnName("changeState")
        val copartnerRatio = EsColumnName("copartnerRatio")
        val couponFreeMoney = EsColumnName("couponFreeMoney")
        val createOpeTime = EsColumnName("createOpeTime")
        val createOper = EsColumnName("createOper")
        val customerName = EsColumnName("customerName")
        val customerUuid = EsColumnName("customerUuid")
        val delFlag = EsColumnName("delFlag")
        val delayDays = EsColumnName("delayDays")
        val distributionMoney = EsColumnName("distributionMoney")
        val distributionRatio = EsColumnName("distributionRatio")
        val distributorState = EsColumnName("distributorState")
        val endTime = EsColumnName("endTime")
        val freight = EsColumnName("freight")
        val fullReduceFreeMoney = EsColumnName("fullReduceFreeMoney")
        val integral = EsColumnName("integral")
        val invoiceEmail = EsColumnName("invoiceEmail")
        val invoiceState = EsColumnName("invoiceState")
        val oneProductDiscount = EsColumnName("oneProductDiscount")
        val opeTime = EsColumnName("opeTime")
        val oper = EsColumnName("oper")
        val orderDetailJson = EsColumnName("orderDetailJson")
        val orderFreePrice = EsColumnName("orderFreePrice")
        val orderGroupUuid = EsColumnName("orderGroupUuid")
        val orderId = EsColumnName("orderId")
        val orderState = EsColumnName("orderState")
        val orderType = EsColumnName("orderType")
        val payPrice = EsColumnName("payPrice")
        val payPriceStr = EsColumnName("payPriceStr")
        val payRatio = EsColumnName("payRatio")
        val payState = EsColumnName("payState")
        val permanentDel = EsColumnName("permanentDel")
        val platCouponFreeMoney = EsColumnName("platCouponFreeMoney")
        val refundMoney = EsColumnName("refundMoney")
        val refundState = EsColumnName("refundState")
        val returnState = EsColumnName("returnState")
        val searchQuery = EsColumnName("searchQuery")
        val sendCouponState = EsColumnName("sendCouponState")
        val sendPointsState = EsColumnName("sendPointsState")
        val serviceFee = EsColumnName("serviceFee")
        val serviceFeeRatio = EsColumnName("serviceFeeRatio")
        val shipType = EsColumnName("shipType")
        val shopState = EsColumnName("shopState")
        val startTime = EsColumnName("startTime")
        val storeDiscount = EsColumnName("storeDiscount")
        val storeName = EsColumnName("storeName")
        val storeSplitRatio = EsColumnName("storeSplitRatio")
        val storeUuid = EsColumnName("storeUuid")
        val sunState = EsColumnName("sunState")
        val tempFreight = EsColumnName("tempFreight")
        val totalFreePrice = EsColumnName("totalFreePrice")
        val totalPrice = EsColumnName("totalPrice")
        val uuid = EsColumnName("uuid")
        val version = EsColumnName("version")
        val payType = EsColumnName("payType")
        val payTime = EsColumnName("payTime")
        val sendTime = EsColumnName("sendTime")
        val receiveTime = EsColumnName("receiveTime")
        val createAt = EsColumnName("createAt")
        val updateAt = EsColumnName("updateAt")
        val id = EsColumnName("id")

    }


    @nbcp.base.db.annotation.DbName(value = """product""")
    @nbcp.base.db.annotation.DbEntityGroup(value = """system""")
    @nbcp.myoql.db.comm.IkFieldDefine(fieldNames = arrayOf("""name""", """slogan""", """detail""", """remark""", """skuDefines.key""", """skuDefines.value"""))
    class ProductIndexEntity(indexName: String = "product"):
        EsBaseMetaEntity<nancal.mp.db.es.entity.ProductIndex>(nancal.mp.db.es.entity.ProductIndex::class.java, indexName) {
        val name = EsColumnName("name")
        val corp = IdNameMeta("corp")
        val slogan = EsColumnName("slogan")
        val brandPath = IdCodeNameMeta("brandPath")
        val corpCategoryPath = IdCodeNameMeta("corpCategoryPath")
        val categoryPath = IdCodeNameMeta("categoryPath")
        val detail = EsColumnName("detail")
        val remark = EsColumnName("remark")
        val status = EsColumnName("status")
        val guidePrice = EsColumnName("guidePrice")
        val skuDefines = KeyValueStringMeta("skuDefines")
        val skuStockPrice = ProductSkuStockPriceMeta("skuStockPrice")
        val createAt = EsColumnName("createAt")
        val updateAt = EsColumnName("updateAt")
        val id = EsColumnName("id")

    }

}

